var postsData = require('../../data/post-data.js');
Page({
  data: {
  },
  onLoad: function (options) {
    //页面初始化 options为页面跳转所带来的参数
    console.log("onLoad");
    //相当与把post_content1放入全局date中
    // this.data.postList = postsData.postList;
    this.setData({ posts_key: postsData.postList });
  },
  onPostTap: function (event) {
    var postId = event.currentTarget.dataset.postId;
    wx.navigateTo({
      url: "./post-detail/post-detail?id=" + postId,
      success: function (res) {
        // success
      },
      fail: function () {
        // fail
      },
      complete: function () {
        // complete
      }
    })
  },
  // target 和currentTarget
  // target指的是当前点击的组件 和currentTarget 指的是事件捕获的组件
  // target这里指的是image，而currentTarget指的是swiper
  onSwiperTap: function (event) {
    var postId = event.target.dataset.postId;
    wx.navigateTo({
      url: "./post-detail/post-detail?id=" + postId,
    })
  }
})